<?php
extract($_POST);
extract($_GET);
require_once("../../PathHelper.php");
require_once $rootPath.'Gazzetta.BL/RSSConfigManager.php';
require_once $rootPath.'Gazzetta.Entities/RSSSource.php';


if(isset($accion))
{
	switch($accion)
	{
	  	  case "add":
		  
		  if(isset($enabled)){
				$enabled = "1";
			}else{
				$enabled ="0";
			}

		  $manager = new RSSConfigManager();
		  $manager->addNewRSSSource($httpRssSource, $title, $idCategory, $description, $enabled);
		  
	  	  break;
		  
		  case "edit":
		  
			if(isset($enabled)){
				$enabled = "1";
			}else{
				$enabled ="0";
			}
	  	  	 $rssConfigManager = new RSSConfigManager();
			 $rssConfigManager->updateRSSSource($idRssSource, $httpRssSource, $title,$idCategory,$description, $enabled);
			 
	  	  break;
	  	  
	  	  
	  	  case "delete":
	  	  
		   $manager = new RSSConfigManager();
	  	   $manager->deleteRSSSource($id);
	  	  
	  	  	break;
	  	  	
	}
	
}
?>
<!DOCTYPE HTML>
<head>
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="flavio" />

	<title>Untitled 2</title>
    <link  href="../styles/admin-panel.css" rel="StyleSheet" type="text/css"/>
    <link  href="../styles/menu.css" rel="StyleSheet" type="text/css"/>
</head>

<body>

<div id="contenedor-header">
    <div id="logo">
    
    </div>
    <div id="contenedor-header-derecho">
        <div id="nombre-usuario">
        
        </div>
        <div id="menu-principal">
        	<?php 
        	include_once("menu.php");
    		?>
        </div>
    </div>
</div>

<div id="contenedor-principal">
<h2>Abm Rss  </h2>
<div id="contenedor_tabla">

<a href="newRssSource.php">Nuevo Rss Source</a>
<?php
echo "</br></br>";

echo "<table>\n";
        	echo
        	'<tr>
        	<th>Id</th>
        	<th>Link</th>
        	<th>Titulo</th>
            <th>Descripcion</th>
			<th>Editar</th>
            <th>Borrar</th>
        	</tr>';
$manager = new RSSConfigManager();
$data = $manager->getAllRSSSources();
foreach ($data as $row) 
        {
			$id = $row->getId();
            $link = $row->getlink();  
			$title = $row->getTitle();
			$description = $row->getDescription();
			$editar="<a href='editRssSource.php?accion=editar&id=".stripslashes($id)."'>Editar</a>";
        	$borrar="<a href='abm-rss-sources.php?accion=delete&id=".stripslashes($id)."'>Borrar</a>";
			echo "<tr>
        	<td>$id</td>
        	<td>$link</td>
        	<td>$title</td>
            <td>$description</td>
			<td>$editar</td>
        	<td>$borrar</td>
			</tr>";
        }
		echo "</table>";
?>
</div>
	
</div>

</body>
</html>